"use strict";
var classCallCheck = function (e, t) {
    if (!(e instanceof t))
      throw new TypeError("Cannot call a class as a function");
  },
  createClass = (function () {
    function e(e, t) {
      for (var i = 0; i < t.length; i++) {
        var s = t[i];
        (s.enumerable = s.enumerable || !1),
          (s.configurable = !0),
          "value" in s && (s.writable = !0),
          Object.defineProperty(e, s.key, s);
      }
    }
    return function (t, i, s) {
      return i && e(t.prototype, i), s && e(t, s), t;
    };
  })(),
  Header = (function () {
    function e(t) {
      var i = this;
      classCallCheck(this, e),
        (this.props = {
          isScrollingTimeoutLength: 1e3,
        }),
        (this.state = {
          lastScrollTop: 0,
          isScrolling: !1,
          isScrollingTimeoutHandler: null,
        }),
        (this.el = t),
        window.addEventListener("scroll", function (e) {
          i.onWindowScroll(e);
        }),
        this.initScrollMagic();
    }
    return (
      createClass(e, [
        {
          key: "onWindowScroll",
          value: function (e) {
            var t = window.pageYOffset || document.documentElement.scrollTop;
            t > this.state.lastScrollTop &&
            this.el.classList.contains("header__transition")
              ? (this.el.classList.remove("header--visible"),
                this.el.classList.add("header--hidden"))
              : (this.el.classList.remove("header--hidden"),
                this.el.classList.add("header--visible")),
              (this.state.lastScrollTop = t <= 0 ? 0 : t);
          },
        },
        {
          key: "scrollTimeout",
          value: function () {
            var e = this;
            (this.state.isScrolling = !0),
              clearTimeout(this.state.isScrollingTimeoutHandler),
              (this.state.isScrollingTimeoutHandler = setTimeout(function () {
                e.el.classList.remove("header--hidden"),
                  e.el.classList.add("header--visible");
              }, this.props.isScrollingTimeoutLength));
          },
        },
        {
          key: "initScrollMagic",
          value: function () {
            var e = new ScrollMagic.Controller();
            new ScrollMagic.Scene({
              offset: 100,
            })
              .setClassToggle("header", "header__transition")
              .addTo(e),
              new ScrollMagic.Scene({
                offset: 500,
              })
                .setClassToggle("header", "header__scrolled")
                .addTo(e);
          },
        },
      ]),
      e
    );
  })(),
  init = function () {
    $("[data-header]").each(function () {
      new Header(this);
    });
  },
  CoverImage = (function () {
    function e(t) {
      var i = this;
      classCallCheck(this, e),
        (this.props = {
          loadedClass: "image--loaded",
          fullHeightClass: "image--full-height",
          fullWidthClass: "image--full-width",
        }),
        (this.img = t),
        (this.parent = t.parentNode),
        (this.slideWrapper = $(t).parents(".slide-wrapper")[0]),
        this.isLoaded() ? this.onLoad() : this.bindLoadEvent(),
        window.addEventListener("resize", function (e) {
          return i.setSize();
        });
    }
    return (
      createClass(e, [
        {
          key: "isLoaded",
          value: function () {
            return this.img.complete;
          },
        },
        {
          key: "bindLoadEvent",
          value: function () {
            this.img.addEventListener("load", this.onLoad.bind(this));
          },
        },
        {
          key: "onLoad",
          value: function () {
            this.img.classList.add(this.props.loadedClass), this.setSize();
          },
        },
        {
          key: "setSize",
          value: function () {
            this.img.classList.remove(
              this.props.fullWidthClass,
              this.props.fullHeightClass
            ),
              this.isFullWidth()
                ? this.img.classList.add(this.props.fullWidthClass)
                : this.img.classList.add(this.props.fullHeightClass);
          },
        },
        {
          key: "isFullWidth",
          value: function () {
            return this.slideWrapper
              ? this.slideWrapper.offsetHeight /
                  this.slideWrapper.offsetWidth <=
                  this.img.naturalHeight / this.img.naturalWidth
              : this.parent.offsetHeight / this.parent.offsetWidth <=
                  this.img.naturalHeight / this.img.naturalWidth;
          },
        },
      ]),
      e
    );
  })(),
  init$1 = function () {
    $("[data-cover-image]").each(function () {
      new CoverImage(this);
    });
  },
  ContainImage = (function () {
    function e(t) {
      var i = this;
      classCallCheck(this, e),
        (this.props = {
          loadedClass: "image--loaded",
          fullHeightClass: "image--full-height",
          fullWidthClass: "image--full-width",
        }),
        (this.img = t),
        (this.parent = t.parentNode),
        (this.slideWrapper = $(t).parents(".slide-wrapper")[0]),
        this.isLoaded() ? this.onLoad() : this.bindLoadEvent(),
        window.addEventListener("resize", function (e) {
          return i.setSize();
        });
    }
    return (
      createClass(e, [
        {
          key: "isLoaded",
          value: function () {
            return this.img.complete;
          },
        },
        {
          key: "bindLoadEvent",
          value: function () {
            this.img.addEventListener("load", this.onLoad.bind(this));
          },
        },
        {
          key: "onLoad",
          value: function () {
            this.img.classList.add(this.props.loadedClass), this.setSize();
          },
        },
        {
          key: "setSize",
          value: function () {
            this.img.classList.remove(
              this.props.fullWidthClass,
              this.props.fullHeightClass
            ),
              this.isFullWidth()
                ? this.img.classList.add(this.props.fullWidthClass)
                : this.img.classList.add(this.props.fullHeightClass);
          },
        },
        {
          key: "isFullWidth",
          value: function () {
            return this.slideWrapper
              ? this.slideWrapper.offsetHeight /
                  this.slideWrapper.offsetWidth <=
                  this.img.naturalHeight / this.img.naturalWidth
              : this.parent.offsetHeight / this.parent.offsetWidth <=
                  this.img.naturalHeight / this.img.naturalWidth;
          },
        },
      ]),
      e
    );
  })(),
  init$2 = function () {
    $("[data-contain-image]").each(function () {
      new ContainImage(this);
    });
  },
  // Slick = (function () {
  //   function e(t) {
  //     classCallCheck(this, e),
  //       (this.props = {}),
  //       (this.mqMobile = window.matchMedia("(min-width: 767px)")),
  //       (this.mqTablet = window.matchMedia("(min-width: 1024px)")),
  //       this.initSlick();
  //   }
  //   return (
  //     createClass(e, [
  //       {
  //         key: "initSlick",
  //         value: function () {
  //           var e = $(".gallery"),
  //             t = $(".gallery-index");
  //           e.on("init reInit afterChange", function (e, i, s, a) {
  //             var n = (s || 0) + 1;
  //             t.text(n + " / " + i.slideCount);
  //           }),
  //             this.mqTablet.matches
  //               ? e.slick({
  //                   arrows: !0,
  //                   accessibility: !0,
  //                   focusOnSelect: !0,
  //                   dots: !1,
  //                 })
  //               : this.mqMobile.matches
  //               ? e.slick({
  //                   arrows: !1,
  //                   accessibility: !0,
  //                   focusOnSelect: !0,
  //                   dots: !1,
  //                 })
  //               : e.slick({
  //                   arrows: !0,
  //                   accessibility: !0,
  //                   focusOnSelect: !0,
  //                   dots: !1,
  //                 });
  //         },
  //       },
  //     ]),
  //     e
  //   );
  // })(),
  // init$3 = function () {
  //   $("[data-main]").each(function () {
  //     new Slick(this);
  //   });
  // },
  SlideShow = (function () {
    function e(t) {
      classCallCheck(this, e),
        (this.el = t),
        (this.props = {
          changeSlide: 0,
        }),
        (this.state = {
          slideIndex: 0,
          slides: this.el.querySelectorAll("[data-slide]"),
          slideIndexLabel: this.el.querySelector("[data-slide-index]"),
          body: this.el.querySelector("[data-body]"),
          title: this.el.querySelector("[data-title]"),
        }),
        this.bindEvents(),
        this.changeSlide(0);
    }
    return (
      createClass(e, [
        {
          key: "bindEvents",
          value: function () {
            var e = this,
              t = new Hammer(this.el);
            t.get("swipe").set({
              direction: Hammer.DIRECTION_HORIZONTAL,
            }),
              t.on("swipeleft swiperight", function (t) {
                return "swipeleft" == t.type ? e.nextSlide() : e.prevSlide();
              }),
              this.el
                .querySelector("[data-next]")
                .addEventListener("click", function (t) {
                  return e.nextSlide();
                }),
              this.el
                .querySelector("[data-prev]")
                .addEventListener("click", function (t) {
                  return e.prevSlide();
                });
          },
        },
        {
          key: "nextSlide",
          value: function () {
            var e = this.state,
              t = e.slideIndex;
            t + 1 > e.slides.length - 1
              ? this.changeSlide(0)
              : this.changeSlide(t + 1);
          },
        },
        {
          key: "prevSlide",
          value: function () {
            var e = this.state,
              t = e.slideIndex,
              i = e.slides;
            t - 1 < 0
              ? this.changeSlide(i.length - 1)
              : this.changeSlide(t - 1);
          },
        },
        {
          key: "changeSlide",
          value: function (e) {
            var t = this.state,
              i = t.slides,
              s = t.slideIndexLabel,
              a = t.body,
              n = t.title;
            Array.prototype.slice.call(i).forEach(function (e) {
              return e.classList.remove("slideshow__content--active");
            }),
              i[e].classList.add("slideshow__content--active"),
              (n.textContent = i[e].getAttribute("data-title-content")),
              (a.textContent = i[e].getAttribute("data-body-content")),
              (s.textContent = e + 1 + " / " + i.length),
              (this.state.slideIndex = e);
          },
        },
        {
          key: "hammerSwipe",
          value: function () {},
        },
      ]),
      e
    );
  })(),
  init$4 = function () {
    $("[data-slideshow]").each(function () {
      new SlideShow(this);
    });
  },
  Windows = (function () {
    function e(t) {
      classCallCheck(this, e), this.initScrollMagic();
    }
    return (
      createClass(e, [
        {
          key: "initScrollMagic",
          value: function () {
            var e = new ScrollMagic.Controller({
              globalSceneOptions: {
                triggerHook: "onEnter",
                duration: "200%",
              },
            });
            new ScrollMagic.Scene({
              triggerElement: "#parallax1",
            })
              .setTween("#parallax1 > div", {
                y: "100%",
                ease: Linear.easeNone,
              })
              .addTo(e),
              new ScrollMagic.Scene({
                triggerElement: "#parallax2",
              })
                .setTween("#parallax2 > div", {
                  y: "100%",
                  ease: Linear.easeNone,
                })
                .addTo(e),
              new ScrollMagic.Scene({
                triggerElement: "#parallax3",
              })
                .setTween("#parallax3 > div", {
                  y: "100%",
                  ease: Linear.easeNone,
                })
                .addTo(e),
              new ScrollMagic.Scene({
                triggerElement: "#parallax-c",
              })
                .setTween("#parallax-c > div", {
                  y: "100%",
                  ease: Linear.easeNone,
                })
                .addTo(e);
          },
        },
      ]),
      e
    );
  })(),
  // init$5 = function () {
  //   $("[data-main]").each(function (e) {
  //     new Windows(this);
  //   });
  // },
  // https://blog.csdn.net/weixin_45930427/article/details/132065597
  // https://blog.csdn.net/sqitarn/article/details/128674238
  FadeIn = function e(t) {
    classCallCheck(this, e),
      (this.el = t),
      AOS.init({
        duration: 600,
        once: true,
      });
  },
  init$6 = function () {
    $("[data-main]").each(function () {
      new FadeIn(this);
    });
  },
  Member = (function () {
    function e(t) {
      classCallCheck(this, e),
        (this.props = {
          loadedClass: "member-bio__closed",
          activeClass: "member-bio__open",
          rotateActiveClass: "link-arrow__up",
          rotateLoadedClass: "link-arrow__down",
        }),
        (this.teamMember = t.querySelector(".member-link")),
        (this.memberBio = t.querySelector(".member-bio")),
        (this.linkArrow = t.querySelector(".link-arrow__down")),
        this.toggleMemberBio(),
        this.onLoad();
    }
    return (
      createClass(e, [
        {
          key: "onLoad",
          value: function () {
            this.memberBio.classList.add(this.props.loadedClass);
          },
        },
        {
          key: "toggleMemberBio",
          value: function () {
            var e = this;
            this.teamMember.addEventListener("click", function (t) {
              e.memberBio.classList.remove(e.props.loadedClass),
                e.memberBio.classList.toggle(e.props.activeClass),
                e.linkArrow.classList.toggle(e.props.rotateActiveClass),
                e.linkArrow.classList.toggle(e.props.rotateLoadedClass);
            });
          },
        },
      ]),
      e
    );
  })(),
  init$7 = function () {
    $("[data-member]").each(function () {
      new Member(this);
    });
  },
  Form = (function () {
    function e(t) {
      classCallCheck(this, e),
        (this.props = {
          loadedClass: "contact__hidden",
          activeClass: "contact__visible",
        }),
        (this.openButton = t.querySelector(".openButton")),
        (this.closeButton = t.querySelector(".closeButton")),
        (this.timeline = t.querySelector("#timeline")),
        (this.contactForm = t.querySelector(".contact__form")),
        (this.contactStatic = t.querySelector(".contact__static")),
        (this.form = t.querySelector("form")),
        this.openForm(),
        this.closeForm(),
        this.submitForm();
    }
    return (
      createClass(e, [
        {
          key: "openForm",
          value: function () {
            var e = this;
            $(".openButton").on("click", function (t) {
              e.contactForm.classList.remove(e.props.loadedClass),
                e.contactForm.classList.add(e.props.activeClass),
                e.contactStatic.classList.remove(e.props.activeClass),
                e.contactStatic.classList.add(e.props.loadedClass),
                setTimeout(function () {
                  $(".nav").addClass("nav__mobile"),
                    $(".nav__hamburger").removeClass("active-one");
                }, 300);
            });
          },
        },
        {
          key: "closeForm",
          value: function () {
            var e = this;
            $(".closeButton").on("click", function (t) {
              e.contactForm.classList.remove(e.props.activeClass),
                e.contactForm.classList.add(e.props.loadedClass),
                e.contactStatic.classList.remove(e.props.loadedClass),
                e.contactStatic.classList.add(e.props.activeClass),
                e.form.reset();
            });
          },
        },
        {
          key: "submitForm",
          value: function () {
            $(this.form).on("submit", function (e) {
              e.preventDefault();
              var t = $("input[name='name']").val(),
                i = $("input[name='email']").val(),
                s = $("input[name='phone']").val(),
                a = $(
                  this.timeline.options[this.timeline.selectedIndex]
                ).text(),
                n = $("textarea[name='message']").val();
              return (
                $.ajax({
                  type: "POST",
                  url: "/wp-json/lucas/v1/mail",
                  data: {
                    email: i,
                    name: t,
                    phone: s,
                    timeline: a,
                    message: n,
                  },
                  success: function () {
                    $("#headline").text(
                      "Thank you, we'll be in touch shortly."
                    ),
                      $("#cta").text("Success"),
                      $(".contact__form").removeClass("contact__visible"),
                      $(".contact__form").addClass("contact__hidden"),
                      $(".contact__static").removeClass("contact__hidden"),
                      $(".contact__static").addClass("contact__visible"),
                      $("form").trigger("reset");
                  },
                  error: function () {
                    alert("Your message could not be sent.");
                  },
                }),
                !1
              );
            });
          },
        },
      ]),
      e
    );
  })(),
  init$8 = function () {
    $("[data-form]").each(function () {
      new Form(this);
    });
  },
  MobileNav = (function () {
    function e(t) {
      var i = this;
      classCallCheck(this, e),
        (this.el = t),
        (this.props = {}),
        (this.state = {
          lastScrollTop: 0,
          isScrolling: !1,
          isScrollingTimeoutHandler: null,
        }),
        this.createMobileNav(),
        window.addEventListener("scroll", function (e) {
          i.onWindowScroll(e);
        });
    }
    return (
      createClass(e, [
        {
          key: "createMobileNav",
          value: function () {
            $(".nav__hamburger").click(function () {
              $(".nav__hamburger").toggleClass("active-one"),
                $(".nav").toggleClass("nav__mobile");
            });
          },
        },
        {
          key: "onWindowScroll",
          value: function () {
            window.pageYOffset || document.documentElement.scrollTop;
            this.state.lastScrollTop,
              $(".nav__hamburger").removeClass("active-one"),
              $(".nav").addClass("nav__mobile");
          },
        },
      ]),
      e
    );
  })(),
  init$9 = function () {
    $("[data-main]").each(function () {
      new MobileNav(this);
    });
  },
  _Symbol = (function () {
    function e(t) {
      classCallCheck(this, e),
        (this.symbolPath = t.querySelector("#draw-path")),
        this.initPathPrepare(),
        this.initScrollMagic(),
        (this.el = t),
        (this.mqLaptop = window.matchMedia("(max-width: 1399px)"));
    }
    return (
      createClass(e, [
        {
          key: "initPathPrepare",
          value: function () {
            !(function (e) {
              var t = e[0].getTotalLength();
              e.css("stroke-dasharray", t), e.css("stroke-dashoffset", t);
            })($(this.symbolPath));
          },
        },
        {
          key: "initScrollMagic",
          value: function () {
            var e = new ScrollMagic.Controller(),
              t = new TimelineMax().add(
                TweenMax.to(this.symbolPath, 1, {
                  strokeDashoffset: 0,
                  ease: Linear.easeNone,
                })
              );
            new ScrollMagic.Scene({
              triggerElement: "#draw-symbol",
              triggerHook: 1,
              duration: 75,
              tweenChanges: !0,
            })
              .setTween(t)
              .addTo(e);
          },
        },
      ]),
      e
    );
  })(),
  init$10 = function () {
    $("[data-footer]").each(function () {
      new _Symbol(this);
    });
  };
document.addEventListener("DOMContentLoaded", function (e) {
  init(),
    init$4(),
    init$1(),
    init$2(),
    // init$3(),
    // init$5(),
    init$6(),
    init$7(),
    init$8(),
    // init$9(),
    init$10();
  if (typeof jQuery === "undefined") {
    // jQuery 未从 CDN 加载，加载本地版本
    console.log("[ cdn坏了 ] >");
    // loadLocalScript("/js/jquery.min.js");
  }
});
function loadLocalScript(src) {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = src;
  document.head.appendChild(script);
}
